home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-21 / api92.zip / DVSEARCH.ZIP / DVSEARCH.C < prev    next >
Text File  |  1992-08-18  |  31KB  |  1,118 lines

  1. /*  DVSEARCH.C
  2.  *  by Dave Haber
  3.  *
  4.  *  Parameters: FILENAME to search
  5.  *       (FONES.DAT in current directory is default)
  6.  *
  7.  *  Version 1.0 - 2/8/92
  8.  *       File format header is derived from line 1 of file if line 1
  9.  *       starts with a ?.  The ? is not printed on the screen.
  10.  *
  11.  *  Version 1.1 - 2/11/92
  12.  *       Program rewritten using win swrite(), win_blanks() and win_putc()
  13.  *       instead of direct screen write calls; program no longer needs to
  14.  *       be virtualized.
  15.  *
  16.  *       Program more completely restores window environment if run from
  17.  *       a DOS prompt.
  18.  *
  19.  *  Version 1.2 - 2/12/92
  20.  *       Info Screen function added.  Program now only opens data file
  21.  *       while searching, then closes it again.  Paused search times out
  22.  *       after two minutes, as does paused info display.
  23.  *
  24.  *  Version 1.3 - 3/26/92
  25.  *       Highlights special entries marked with  (02),  (03) or  (04).
  26.  *       Highlights 03 and 04 only show when program started with /h.
  27.  *       Changed ? to  (01).
  28.  *       Will display complete file by entering *.
  29.  *       [F1] accesses HELP.DAT, [F2] through [F9] access F2.DAT through F9.DAT
  30.  *       added default help functions
  31.  *
  32.  *  Version 2.0 - 4/1/92
  33.  *       Added immediate searching
  34.  *       immediate mode startup parameter /i
  35.  *
  36.  *  Version 2.1 - 4/8/92
  37.  *       Added ability to break out of help file with another help key
  38.  *
  39.  *  Version 2.2 - 4/9/92
  40.  *       Added Beep on unsucessful search, /q for quiet
  41.  *       corrected bug in searches containing space
  42.  *       removed default help screens
  43.  *       cleaned up /k keyboard hack parameter
  44.  *
  45.  *  Version 2.3 - 4/14/92
  46.  *       Removed file not found messages
  47.  *       added /x "exit" command parameter
  48.  *
  49.  *  Version 2.4 - 5/19/92
  50.  *       Removed window move restriction
  51.  *       Added TAB abbreviated screen command
  52.  *
  53.  *  Version 2.5 - 5/20/92
  54.  *       Added /s small startup option
  55.  *       added small help screens
  56.  *
  57.  *  Version 2.6 - 5/28/92
  58.  *       fixed bug in search timeout
  59.  *
  60.  *  Version 2.7 - 6/1/92
  61.  *       changed inkey to wait for keystroke rather than poll for it
  62.  *       added api_pause() where polling must occur
  63.  *
  64.  *  Version 3.0 - 6/22/92
  65.  *       added history commands
  66.  *       added [F10] - [F12] info screen ability
  67.  */
  68.  
  69.  
  70.  
  71. #include <stdio.h>
  72. #include <ctype.h>
  73. #include "gfuncts.h"  /* declarations for Greenleaf Functions */
  74. #include "string.h"
  75. #include "dvapi.h"
  76.  
  77. #define REQUIRED 0x200
  78.  
  79. #define PGMVER "3.0"
  80.  
  81. /* color definitions*/
  82. #define TEXT 31
  83. #define LOGO 30        /* should have same background as TEXT */
  84. #define DATA 49
  85. #define HILITE1 52
  86. #define HILITE2 63
  87. #define HILITE3 62
  88. #define PROMPT0 79
  89. #define PROMPT1 95
  90. #define HELP 47
  91. #define EMERGENCY 79
  92. #define INFO 113
  93.  
  94. void clrwin(int);
  95. void inkey(int,int,int);
  96. void info(int);
  97. void qdlogo(void);
  98. void getsmall(void);
  99. void fin(void);
  100.  
  101. char instr[81];
  102. char savkey0[21], savkey1[21], savkey2[21], savkey3[21], savkey4[21];
  103. char savkey5[21], savkey6[21], savkey7[21], savkey8[21], savkey9[21];
  104. int winattr,frameattr,posrow,poscol,sizerow,sizecol,keyhack,savkey,savpos=0;
  105. int immediate,allowexit,prompt,clear=0,prow,pcol,position=0,small=0;
  106. int tempquiet=0;
  107. ulong me;
  108.  
  109. main(int argc, char **argv)
  110. {
  111.  
  112. FILE *infile;
  113. char filename[13], string[81], lcstr[81], fxdstr[81];
  114. char findit[31], headerstr[81];
  115. int loop,apiver,place,key,abort,header,virgin,hilite;
  116. int eatit=0,foundit,quiet,bale;
  117. ulong maintime, interval=12000;
  118.  
  119.     apiver=api_init();
  120.     if(apiver<REQUIRED)
  121.         {
  122.         printf("\nThis program requires DESQview version %d.%02d or later.\n",
  123.             REQUIRED/256,REQUIRED%256);
  124.         printf("\nIf you don't own DESQview, you don't know what you're missing!");
  125.         printf("\nCall 1-800-354-3222 and say, \"I WANT MY DV!\"\n\n");
  126.         api_exit();
  127.         exit(1);
  128.         }        
  129.     
  130.     hilite=0;
  131.     if(!strcmp(argv[1],"/h") || !strcmp(argv[2],"/h") || !strcmp(argv[3],"/h")
  132.         || !strcmp(argv[4],"/h") || !strcmp(argv[5],"/h"))
  133.         hilite=1;
  134.  
  135.     keyhack=0;
  136.     if(!strcmp(argv[1],"/k") || !strcmp(argv[2],"/k") || !strcmp(argv[3],"/k")
  137.         || !strcmp(argv[4],"/k") || !strcmp(argv[5],"/k"))
  138.         keyhack=1;
  139.  
  140.     quiet=0;
  141.     if(!strcmp(argv[1],"/q") || !strcmp(argv[2],"/q") || !strcmp(argv[3],"/q")
  142.         || !strcmp(argv[4],"/q") || !strcmp(argv[5],"/q"))
  143.         quiet=1;
  144.  
  145.     allowexit=0;
  146.     if(!strcmp(argv[1],"/x") || !strcmp(argv[2],"/x") || !strcmp(argv[3],"/x")
  147.         || !strcmp(argv[4],"/x") || !strcmp(argv[5],"/x"))
  148.         allowexit=1;
  149.  
  150.     small=0;
  151.     if(!strcmp(argv[1],"/s") || !strcmp(argv[2],"/s") || !strcmp(argv[3],"/s")
  152.         || !strcmp(argv[4],"/s") || !strcmp(argv[5],"/s"))
  153.         small=1;
  154.  
  155.     immediate=0;
  156.     prompt=PROMPT0;
  157.     if(!strcmp(argv[1],"/i") || !strcmp(argv[2],"/i") || !strcmp(argv[3],"/i")
  158.         || !strcmp(argv[4],"/i") || !strcmp(argv[5],"/i"))
  159.         {
  160.         immediate=1;
  161.         prompt=PROMPT1;
  162.         }
  163.  
  164.     if(argc<2 || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/k") ||
  165.         !strcmp(argv[1],"/i") || !strcmp(argv[1],"/q") ||
  166.         !strcmp(argv[1],"/x") || !strcmp(argv[1],"/s"))
  167.         strcpy(filename,"FONES.DAT");
  168.     else
  169.         strcpy(filename,argv[1]);
  170.         
  171.     /* fexist() is a Greenleaf Function which checks for the
  172.        existance of a file */
  173.  
  174.     if(!fexist(filename))
  175.         {
  176.         printf("\n\nCannot find file: %s\n\n",filename);
  177.         api_exit();
  178.         exit(1);
  179.         }
  180.  
  181.     me=win_me();           /* get win_me() for all future calls */
  182.                            /* that require winhandle */
  183.     maintime=tim_new();
  184.         
  185.     winattr=qry_attr(me);
  186.     frameattr=qry_frattr(me,255);
  187.     qry_size(me,&sizerow,&sizecol);
  188.     qry_position(me,&posrow,&poscol);
  189.  
  190.     win_resize(me,14,78);
  191.     /* win_move(me,5,1); */
  192.     
  193.     win_disallow(me,ALW_HSIZE);
  194.     win_disallow(me,ALW_VSIZE);
  195.     win_disallow(me,ALW_HSCROLL);
  196.     win_disallow(me,ALW_VSCROLL);
  197.      app_foreonly(me,0);                    /* makes app run in background no */
  198.                                         /* matter what PIF is set to. */
  199.      win_origin(me,0,0);    
  200.     win_frattr(me,255,TEXT);
  201.     
  202.     key_subfrom(key_me(),KBF_CURSOR);
  203.     
  204.     if(small)
  205.         {
  206.         win_allow(me,ALW_HSIZE);
  207.         win_allow(me,ALW_VSIZE);
  208.         win_resize(me,14,42);
  209.         win_disallow(me,ALW_HSIZE);
  210.         win_disallow(me,ALW_VSIZE);
  211.         win_redraw(me);
  212.         }
  213.  
  214.     memset(savkey1, '\0',21);
  215.     memset(savkey2, '\0',21);
  216.     memset(savkey3, '\0',21);
  217.     memset(savkey4, '\0',21);
  218.     memset(savkey5, '\0',21);
  219.     memset(savkey6, '\0',21);
  220.     memset(savkey7, '\0',21);
  221.     memset(savkey8, '\0',21);
  222.     memset(savkey9, '\0',21);
  223.     memset(savkey0, '\0',21);
  224.  
  225.     header=0;
  226.     memset(headerstr,'\0',81);
  227.     infile=fopen(filename,"r");
  228.     fgets(string,80,infile);
  229.     if(string[0]=='')
  230.         {
  231.         /* strxlf() and strxrt() are Greenleaf Functions that
  232.            perform string extraction */
  233.         strxlf(headerstr,string,strlen(string)-1);
  234.         strxrt(headerstr,headerstr,strlen(headerstr)-1);
  235.         header=1;
  236.         }
  237.     else
  238.         {
  239.         strcpy(headerstr,"                       DESQview File Search Utility");
  240.         }
  241.     fclose(infile);
  242.                 
  243.     win_attr(me,TEXT);
  244.     win_redraw(me);
  245.     win_erase(me);
  246.     win_cursor(me,0,0);
  247.     win_blanks(me,78);
  248.     win_cursor(me,1,0);
  249.     win_swrite(me,"──────────────────────────────────────────────────────────────────────────────");
  250.     win_cursor(me,12,0);
  251.     win_swrite(me,"══════════════════════════════════════════════════════════════════════════════");
  252.  
  253.     qdlogo();
  254.     
  255.     memset(instr, '\0', 81);
  256.     memset(string,'\0', 81);
  257.  
  258.     virgin=1;
  259.     while(1)
  260.         {
  261.         if(!immediate || virgin)
  262.             {
  263.             win_attr(me,TEXT);
  264.             win_cursor(me,13,0);
  265.             win_swrite(me," Search for: ");
  266.             win_cursor(me,13,66);
  267.             win_swrite(me,"[F1] Help");
  268.             win_cursor(me,13,13);
  269.             win_attr(me,prompt);
  270.             win_blanks(me,20);
  271.             win_attr(me,TEXT);
  272.             win_blanks(me,32);
  273.             prow=13;
  274.             pcol=13;
  275.             }
  276.         
  277.         inkey(prow,pcol,20);                /* get search string; row,col,max */
  278.         strcpy(findit,instr);
  279.         strlwr(findit);
  280.  
  281.         if(virgin)                                    /* print header string on */
  282.             {                                            /* first go around only */
  283.             win_attr(me,TEXT);
  284.             win_cursor(me,0,1);
  285.             win_swrite(me,headerstr);
  286.             virgin=0;
  287.             }
  288.     
  289.         clrwin(DATA);    
  290.  
  291.         place=2;
  292.         abort=0;
  293.         bale=0;
  294.         infile=fopen(filename,"r");
  295.         if(header)                                        /* if file has header */
  296.             fgets(string,80,infile);                 /* eat first line of file */
  297.         foundit=0;
  298.         while(fgets(string,80,infile)!=NULL && !abort)
  299.             {
  300.             strcpy(lcstr,string);
  301.             strlwr(lcstr);
  302.             if((strfind(lcstr,findit)!=-1 || findit[0]=='*') && lcstr[0]!='')
  303.                 {
  304.                 foundit=1;
  305.                 if(place>11)
  306.                     {
  307.                     if(!immediate)
  308.                         {
  309.                         win_attr(me,TEXT);
  310.                         win_cursor(me,13,0);
  311.                         win_swrite(me," Hit [PgDn] for More or [ESC]                                                ");
  312.                         tim_addto(maintime,interval);
  313.                         bale=0;
  314.                         while(!bale&&!abort)                          /* loop while no key is pressed */
  315.                             {
  316.                             while(!gfkbhit()&&!abort)
  317.                             /* gfkbhit() is a Greenleaf Function that
  318.                                waits for keyboard activity */
  319.                                 {
  320.                                 if(!tim_len(maintime))
  321.                                     {
  322.                                     abort=1;
  323.                                     tim_close(maintime);
  324.                                     }
  325.                                 api_pause();
  326.                                 }
  327.                             if(!abort)
  328.                                 key=getkey();
  329.                                 /* getkey() is a Greenleaf Function */
  330.                             bale=1;
  331.                             if(key==9)
  332.                                 {
  333.                                 getsmall();
  334.                                 bale=0;
  335.                                 }
  336.                             }
  337.                         if(key==27 || clear)
  338.                             {
  339.                             abort=1;
  340.                             position=0;
  341.                             clear=0;
  342.                             }
  343.                         if(key!=27 && !abort)
  344.                             clrwin(DATA);
  345.                         place=2;
  346.                         }
  347.                     else
  348.                         {
  349.                         abort=1;
  350.                         }
  351.                     }
  352.                 if(!abort)
  353.                     {
  354.                     win_attr(me,DATA);
  355.                     if(string[0]=='')
  356.                         {
  357.                         win_attr(me,HILITE1);
  358.                         eatit=1;
  359.                         }
  360.                     if(string[0]=='')
  361.                         {
  362.                         if(hilite)
  363.                             win_attr(me,HILITE2);
  364.                         eatit=1;
  365.                         }
  366.                     if(string[0]=='')
  367.                         {
  368.                         if(hilite)
  369.                             win_attr(me,HILITE3);
  370.                         eatit=1;
  371.                         }
  372.                     if(eatit)
  373.                         {
  374.                         strxrt(string,string,strlen(string)-1);
  375.                         eatit=0;
  376.                         }
  377.                     win_cursor(me,place,1);
  378.                     win_swrite(me,string);
  379.                     }
  380.                 place++;
  381.                 }
  382.             }
  383.         
  384.         if(!foundit && !quiet && !tempquiet)
  385.             {
  386.             api_sound(400,2);
  387.             api_sound(200,2);
  388.             }
  389.         if(tempquiet)
  390.             tempquiet=0;
  391.         fclose(infile);
  392.         }                          /* end of main loop */
  393.         
  394. }                                            /* end of program */
  395.  
  396.  
  397.  
  398. void clrwin(int attrib)
  399. {
  400. int loop,line;
  401.  
  402. win_attr(me,attrib);
  403. win_cursor(me,2,0);            /* beginning of data window */
  404. win_blanks(me,800);
  405.  
  406. }
  407.  
  408.  
  409. void inkey(int inrow, int incol, int max)
  410. {
  411. int key, wait, finished, escape=0;
  412. char string[81];
  413. int row,col;
  414.  
  415. if(max>80)
  416.     max=80;
  417.  
  418. memset(string, '\0', 81);
  419. if(immediate)
  420.     {
  421.     strcpy(string, instr);
  422.     }
  423.  
  424. win_cursor(me,inrow,incol);
  425. key_addto(key_me(),KBF_CURSOR);
  426.  
  427. row=inrow;
  428. col=incol;
  429. finished=0;
  430. while(!finished)                    /* while Enter not pushed */
  431.     {
  432.     if(savkey)
  433.         {
  434.         key=savkey;
  435.         savkey=0;
  436.         }
  437.     else
  438.         {
  439.         key=getkey();
  440.         /* getkey() is a Greenleaf Function */
  441.         }
  442.  
  443.     if (keyhack)
  444.         {
  445.         win_cursor(me,0,2);
  446.         win_swrite(me,"        ");
  447.         win_cursor(me,0,2);
  448.         win_printf(me,"%d",key);
  449.         win_cursor(me,row,col);
  450.         }
  451.  
  452.     if(key==11520)                  /* Alt-X */
  453.         fin();
  454.     if(key==13)                     /* Enter Key */
  455.         {
  456.         finished=1;
  457.         savpos=0;
  458.         }
  459.     if(key==5888)                   /* Alt-I */
  460.         {
  461.         if(immediate)
  462.             {
  463.             immediate=0;
  464.             prompt=PROMPT0;
  465.             finished=1;
  466.             tempquiet=1;
  467.             }
  468.         else
  469.             {
  470.             immediate=1;
  471.             prompt=PROMPT1;
  472.             }
  473.         escape=1;
  474.         }
  475.     if(key==9)
  476.         getsmall();
  477.     if(key==27 || escape==1)                     /* Escape Key */
  478.         {
  479.         escape=0;
  480.         savpos=0;
  481.         memset(instr, '\0', 81);
  482.         memset(string,'\0', 81);
  483.         position=0;
  484.         row=13;
  485.         col=13;
  486.         win_attr(me,TEXT);
  487.         win_cursor(me,13,0);
  488.         win_swrite(me," Search for: ");
  489.         win_cursor(me,13,66);
  490.         win_swrite(me,"[F1] Help");
  491.         win_cursor(me,13,13);
  492.         win_attr(me,prompt);
  493.         win_blanks(me,20);
  494.         win_attr(me,TEXT);
  495.         win_blanks(me,32);
  496.         prow=13;
  497.         pcol=13;
  498.         win_cursor(me,row,col);
  499.         win_hcur(me);
  500.         memset(instr, '\0', 81);
  501.         memset(string,'\0', 81);
  502.         position=0;
  503.         }
  504.  
  505.     if((key==18432 || key==20480) && !immediate)    /* Up, Down Arrows */
  506.         {
  507.         if(key==18432)
  508.             {
  509.             savpos++;
  510.             if(savpos>10)
  511.                 {
  512.                 api_sound(1000,1);
  513.                 savpos=10;
  514.                 }
  515.             }
  516.         if(key==20480)
  517.             {
  518.             savpos--;
  519.             if(savpos<1)
  520.                 {
  521.                 api_sound(1000,1);
  522.                 savpos=1;
  523.                 }
  524.             }
  525.         if(savpos==1)
  526.             strcpy(string,savkey0);
  527.         if(savpos==2)
  528.             strcpy(string,savkey1);
  529.         if(savpos==3)
  530.             strcpy(string,savkey2);
  531.         if(savpos==4)
  532.             strcpy(string,savkey3);
  533.         if(savpos==5)
  534.             strcpy(string,savkey4);
  535.         if(savpos==6)
  536.             strcpy(string,savkey5);
  537.         if(savpos==7)
  538.             strcpy(string,savkey6);
  539.         if(savpos==8)
  540.             strcpy(string,savkey7);
  541.         if(savpos==9)
  542.             strcpy(string,savkey8);
  543.         if(savpos==10)
  544.             strcpy(string,savkey9);
  545.         position=strlen(string);
  546.         win_cursor(me,row,incol);
  547.         win_attr(me,prompt);
  548.         win_blanks(me,20);
  549.         win_cursor(me,row,incol);
  550.         win_swrite(me,string);
  551.         col=incol+position;
  552.         win_cursor(me,row,col);
  553.         win_hcur(me);
  554.         }
  555.     if(key==8||key==19200)      /* Backspace or Left Arrow */
  556.         if(position>0)      
  557.             {
  558.             string[position-1]='\0';
  559.             col--;
  560.             position--;
  561.             win_attr(me,prompt);
  562.             win_cursor(me,row,col);
  563.             win_swrite(me," ");
  564.             win_cursor(me,row,col);
  565.             win_hcur(me);
  566.             }
  567.     if(key==15104)                  /* [F1] */
  568.         {
  569.         win_cursor(me,13,77);
  570.         win_hcur(me);
  571.         key_subfrom(key_me(),KBF_CURSOR);
  572.         info(1);
  573.         win_attr(me,prompt);
  574.         win_cursor(me,13,13);
  575.         win_swrite(me,string);
  576.         key_addto(key_me(),KBF_CURSOR);
  577.         win_cursor(me,row,col);
  578.         win_hcur(me);
  579.         }
  580.     if(key==15360)                  /* [F2] */
  581.         {
  582.         win_cursor(me,13,77);
  583.         win_hcur(me);
  584.         key_subfrom(key_me(),KBF_CURSOR);
  585.         info(2);
  586.         win_attr(me,prompt);
  587.         win_cursor(me,13,13);
  588.         win_swrite(me,string);
  589.         key_addto(key_me(),KBF_CURSOR);
  590.         win_cursor(me,row,col);
  591.         win_hcur(me);
  592.         }
  593.     if(key==15616)                  /* [F3] */
  594.         {
  595.         win_cursor(me,13,77);
  596.         win_hcur(me);
  597.         key_subfrom(key_me(),KBF_CURSOR);
  598.         info(3);
  599.         win_attr(me,prompt);
  600.         win_cursor(me,13,13);
  601.         win_swrite(me,string);
  602.         key_addto(key_me(),KBF_CURSOR);
  603.         win_cursor(me,row,col);
  604.         win_hcur(me);
  605.         }
  606.     if(key==15872)                  /* [F4] */
  607.         {
  608.         win_cursor(me,13,77);
  609.         win_hcur(me);
  610.         key_subfrom(key_me(),KBF_CURSOR);
  611.         info(4);
  612.         win_attr(me,prompt);
  613.         win_cursor(me,13,13);
  614.         win_swrite(me,string);
  615.         key_addto(key_me(),KBF_CURSOR);
  616.         win_cursor(me,row,col);
  617.         win_hcur(me);
  618.         }
  619.     if(key==16128)                  /* [F5] */
  620.         {
  621.         win_cursor(me,13,77);
  622.         win_hcur(me);
  623.         key_subfrom(key_me(),KBF_CURSOR);
  624.         info(5);
  625.         win_attr(me,prompt);
  626.         win_cursor(me,13,13);
  627.         win_swrite(me,string);
  628.         key_addto(key_me(),KBF_CURSOR);
  629.         win_cursor(me,row,col);
  630.         win_hcur(me);
  631.         }
  632.     if(key==16384)                  /* [F6] */
  633.         {
  634.         win_cursor(me,13,77);
  635.         win_hcur(me);
  636.         key_subfrom(key_me(),KBF_CURSOR);
  637.         info(6);
  638.         win_attr(me,prompt);
  639.         win_cursor(me,13,13);
  640.         win_swrite(me,string);
  641.         key_addto(key_me(),KBF_CURSOR);
  642.         win_cursor(me,row,col);
  643.         win_hcur(me);
  644.         }
  645.     if(key==16640)                  /* [F7] */
  646.         {
  647.         win_cursor(me,13,77);
  648.         win_hcur(me);
  649.         key_subfrom(key_me(),KBF_CURSOR);
  650.         info(7);
  651.         win_attr(me,prompt);
  652.         win_cursor(me,13,13);
  653.         win_swrite(me,string);
  654.         key_addto(key_me(),KBF_CURSOR);
  655.         win_cursor(me,row,col);
  656.         win_hcur(me);
  657.         }
  658.     if(key==16896)                  /* [F8] */
  659.         {
  660.         win_cursor(me,13,77);
  661.         win_hcur(me);
  662.         key_subfrom(key_me(),KBF_CURSOR);
  663.         info(8);
  664.         win_attr(me,prompt);
  665.         win_cursor(me,13,13);
  666.         win_swrite(me,string);
  667.         key_addto(key_me(),KBF_CURSOR);
  668.         win_cursor(me,row,col);
  669.         win_hcur(me);
  670.         }
  671.     if(key==17152)                  /* [F9] */
  672.         {
  673.         win_cursor(me,13,77);
  674.         win_hcur(me);
  675.         key_subfrom(key_me(),KBF_CURSOR);
  676.         info(9);
  677.         win_attr(me,prompt);
  678.         win_cursor(me,13,13);
  679.         win_swrite(me,string);
  680.         key_addto(key_me(),KBF_CURSOR);
  681.         win_cursor(me,row,col);
  682.         win_hcur(me);
  683.         }
  684.     if(key==17408)                  /* [F10] */
  685.         {
  686.         win_cursor(me,13,77);
  687.         win_hcur(me);
  688.         key_subfrom(key_me(),KBF_CURSOR);
  689.         info(10);
  690.         win_attr(me,prompt);
  691.         win_cursor(me,13,13);
  692.         win_swrite(me,string);
  693.         key_addto(key_me(),KBF_CURSOR);
  694.         win_cursor(me,row,col);
  695.         win_hcur(me);
  696.         }
  697.     if(key==-31488)                  /* [F11] */
  698.         {
  699.         win_cursor(me,13,77);
  700.         win_hcur(me);
  701.         key_subfrom(key_me(),KBF_CURSOR);
  702.         info(11);
  703.         win_attr(me,prompt);
  704.         win_cursor(me,13,13);
  705.         win_swrite(me,string);
  706.         key_addto(key_me(),KBF_CURSOR);
  707.         win_cursor(me,row,col);
  708.         win_hcur(me);
  709.         }
  710.     if(key==-31232)                  /* [F12] */
  711.         {
  712.         win_cursor(me,13,77);
  713.         win_hcur(me);
  714.         key_subfrom(key_me(),KBF_CURSOR);
  715.         info(12);
  716.         win_attr(me,prompt);
  717.         win_cursor(me,13,13);
  718.         win_swrite(me,string);
  719.         key_addto(key_me(),KBF_CURSOR);
  720.         win_cursor(me,row,col);
  721.         win_hcur(me);
  722.         }
  723.     if(key==7680)                   /* Alt-A */
  724.         {
  725.         key_subfrom(key_me(),KBF_CURSOR);
  726.         qdlogo();
  727.         key_addto(key_me(),KBF_CURSOR);
  728.         win_cursor(me,row,col);
  729.         win_hcur(me);
  730.         }
  731.  
  732.     if(key>29 && key<127)
  733.         if(position<max)
  734.             {
  735.             string[position]=key;
  736.             win_cursor(me,row,col);
  737.             win_putc(me,key,prompt);
  738.             col++;
  739.             position++;
  740.             win_cursor(me,row,col);
  741.             win_hcur(me);
  742.             }
  743.  
  744.     if(immediate==1 && position>1)
  745.         finished=1;
  746.     }
  747.  
  748. if(strlen(string)>0)
  749.     {
  750.     strcpy(savkey9, savkey8);
  751.     strcpy(savkey8, savkey7);
  752.     strcpy(savkey7, savkey6);
  753.     strcpy(savkey6, savkey5);
  754.     strcpy(savkey5, savkey4);
  755.     strcpy(savkey4, savkey3);
  756.     strcpy(savkey3, savkey2);
  757.     strcpy(savkey2, savkey1);
  758.     strcpy(savkey1, savkey0);
  759.     strcpy(savkey0, string);
  760.     }
  761.  
  762. memset(instr,'\0', 81);
  763. strcpy(instr,string);
  764. if(!immediate)
  765.     {
  766.     memset(string,'\0', 81);
  767.     position=0;
  768.     }
  769.  
  770. if(!strcmp(instr,"exit") && allowexit)
  771.     fin();
  772.  
  773. prow=row;
  774. pcol=col;
  775. win_cursor(me,11,77);
  776. win_hcur(me);
  777. key_subfrom(key_me(),KBF_CURSOR);
  778.  
  779.  
  780. }    
  781.  
  782.  
  783. void info(int keyno)
  784. {
  785.     FILE *helpfile;
  786.     char string[81];
  787.     int key=0,place,abort,color;
  788.     ulong infotime, interval=12000;
  789.     char fname[20];
  790.  
  791.     infotime=tim_new();
  792.     savkey=0;
  793.  
  794.     if(keyno==1)
  795.         {
  796.         if(small && fexist("help.sml"))  /* fexist() is a Greenleaf Function */
  797.             strcpy(fname,"help.sml");    /*    that checks for the existance */
  798.         else                             /*    of a file */
  799.             {
  800.             if(small && fexist("help.dat"))
  801.                 getsmall();
  802.             strcpy(fname,"help.dat");
  803.             }
  804.         color=HELP;
  805.         }
  806.     if(keyno==2)
  807.         {
  808.         if(small && fexist("f2.sml"))
  809.             strcpy(fname,"f2.sml");
  810.         else
  811.             {
  812.             if(small && fexist("f2.dat"))
  813.                 getsmall();
  814.             strcpy(fname,"f2.dat");
  815.             }
  816.         color=INFO;
  817.         }
  818.     if(keyno==3)
  819.         {
  820.         if(small && fexist("f3.sml"))
  821.             strcpy(fname,"f3.sml");
  822.         else
  823.             {
  824.             if(small && fexist("f3.dat"))
  825.                 getsmall();
  826.             strcpy(fname,"f3.dat");
  827.             }
  828.         color=INFO;
  829.         }
  830.     if(keyno==4)
  831.         {
  832.         if(small && fexist("f4.sml"))
  833.             strcpy(fname,"f4.sml");
  834.         else
  835.             {
  836.             if(small && fexist("f4.dat"))
  837.                 getsmall();
  838.             strcpy(fname,"f4.dat");
  839.             }
  840.         color=INFO;
  841.         }
  842.     if(keyno==5)
  843.         {
  844.         if(small && fexist("f5.sml"))
  845.             strcpy(fname,"f5.sml");
  846.         else
  847.             {
  848.             if(small && fexist("f5.dat"))
  849.                 getsmall();
  850.             strcpy(fname,"f5.dat");
  851.             }
  852.         color=INFO;
  853.         }
  854.     if(keyno==6)
  855.         {
  856.         if(small && fexist("f6.sml"))
  857.             strcpy(fname,"f6.sml");
  858.         else
  859.             {
  860.             if(small && fexist("f6.dat"))
  861.                 getsmall();
  862.             strcpy(fname,"f6.dat");
  863.             }
  864.         color=INFO;
  865.         }
  866.     if(keyno==7)
  867.         {
  868.         if(small && fexist("f7.sml"))
  869.             strcpy(fname,"f7.sml");
  870.         else
  871.             {
  872.             if(small && fexist("f7.dat"))
  873.                 getsmall();
  874.             strcpy(fname,"f7.dat");
  875.             }
  876.         color=INFO;
  877.         }
  878.     if(keyno==8)
  879.         {
  880.         if(small && fexist("f8.sml"))
  881.             strcpy(fname,"f8.sml");
  882.         else
  883.             {
  884.             if(small && fexist("f8.dat"))
  885.                 getsmall();
  886.             strcpy(fname,"f8.dat");
  887.             }
  888.         color=INFO;
  889.         }
  890.     if(keyno==9)
  891.         {
  892.         if(small && fexist("f9.sml"))
  893.             strcpy(fname,"f9.sml");
  894.         else
  895.             {
  896.             if(small && fexist("f9.dat"))
  897.                 getsmall();
  898.             strcpy(fname,"f9.dat");
  899.             }
  900.         color=EMERGENCY;
  901.         }
  902.     if(keyno==10)
  903.         {
  904.         if(small && fexist("f10.sml"))
  905.             strcpy(fname,"f10.sml");
  906.         else
  907.             {
  908.             if(small && fexist("f10.dat"))
  909.                 getsmall();
  910.             strcpy(fname,"f10.dat");
  911.             }
  912.         color=INFO;
  913.         }
  914.     if(keyno==11)
  915.         {
  916.         if(small && fexist("f11.sml"))
  917.             strcpy(fname,"f11.sml");
  918.         else
  919.             {
  920.             if(small && fexist("f11.dat"))
  921.                 getsmall();
  922.             strcpy(fname,"f11.dat");
  923.             }
  924.         color=INFO;
  925.         }
  926.     if(keyno==12)
  927.         {
  928.         if(small && fexist("f12.sml"))
  929.             strcpy(fname,"f12.sml");
  930.         else
  931.             {
  932.             if(small && fexist("f12.dat"))
  933.                 getsmall();
  934.             strcpy(fname,"f12.dat");
  935.             }
  936.         color=INFO;
  937.         }
  938.  
  939.     if(fexist(fname))
  940.         {
  941.         helpfile=fopen(fname,"r");
  942.  
  943.         clrwin(color);
  944.     
  945.         place=2;
  946.         abort=0;
  947.         while(fgets(string,80,helpfile)!=NULL && !abort)
  948.             {
  949.             if(place>11)
  950.                 {
  951.                 win_attr(me,TEXT);
  952.                 win_cursor(me,13,0);
  953.                 win_swrite(me," Hit [PgDn] for More or [ESC]                                                 ");
  954.                 win_attr(me,HELP);
  955.                 tim_addto(infotime,interval);
  956.                 while(!gfkbhit() && !abort)      /* loop while no key is pressed */
  957.                     {
  958.                     if(!tim_len(infotime))
  959.                         {
  960.                         abort=1;
  961.                         tim_close(infotime);
  962.                         }
  963.                     api_pause();
  964.                     }
  965.                 if(!abort)
  966.                     key=getkey();
  967.                     /* getkey() is a Greenleaf Function */
  968.                 if(key==27)
  969.                     abort=1;
  970.                 if(key==15104 || key==15360 || key==15616 || key==15872
  971.                     || key==16128 || key==16384 || key==16640 || key==16896
  972.                     || key==17152 || key==17408 || key==-31488 || key==-31282)
  973.                     {
  974.                     abort=1;
  975.                     savkey=key;
  976.                     }
  977.                 if(key!=27 && !abort)
  978.                     clrwin(color);
  979.                 place=2;
  980.                 }
  981.             if(!abort)
  982.                 {
  983.                 win_cursor(me,place,1);
  984.                 win_swrite(me,string);
  985.                 }
  986.             place++;
  987.             }
  988.             
  989.     fclose(helpfile);
  990.  
  991.     if(immediate && position>1 && !abort)
  992.             {
  993.             win_attr(me,TEXT);
  994.             win_cursor(me,13,0);
  995.             win_swrite(me," Hit any key to continue...                                                 ");
  996.             tim_addto(infotime,interval);
  997.             while(!gfkbhit() && !abort)   /* loop while no key is pressed */
  998.                 {
  999.                 if(!tim_len(infotime))
  1000.                     abort=1;
  1001.                 api_pause();
  1002.                 }
  1003.             key=getkey();
  1004.             /* getkey() is a Greenleaf Function */
  1005.             if(key==15104 || key==15360 || key==15616 || key==15872
  1006.                 || key==16128 || key==16384 || key==16640 || key==16896
  1007.                 || key==17152 || key==17408 || key==-31488 || key==-31232)
  1008.                 {
  1009.                 savkey=key;
  1010.                 }
  1011.             abort=1;
  1012.             }
  1013.  
  1014.         win_attr(me,TEXT);
  1015.         win_cursor(me,13,0);
  1016.         win_swrite(me," Search for: ");
  1017.         win_cursor(me,13,66);
  1018.         win_swrite(me,"[F1] Help");
  1019.         win_cursor(me,13,13);
  1020.         win_attr(me,prompt);
  1021.         win_blanks(me,20);
  1022.         win_attr(me,TEXT);
  1023.         win_blanks(me,32);
  1024.         }
  1025.  
  1026.     tim_free(infotime);
  1027.  
  1028. }
  1029.  
  1030.  
  1031. void qdlogo(void)
  1032. {
  1033.     int key;
  1034.  
  1035.     clrwin(LOGO);
  1036.     
  1037.     win_attr(me,LOGO);
  1038.     if(!small)
  1039.         {
  1040.         win_cursor(me,3,12); win_swrite(me,"┌──────────────────────────────┐ ───────────────────▄─");
  1041.         win_cursor(me,4,12); win_swrite(me,"│ DESQview File Search Utility │ ────────────────▄▄▄──");
  1042.         win_cursor(me,5,12); win_swrite(me,"│         Version              │ ─────────────▄▄▄▄▄───");
  1043.         win_cursor(me,6,12); win_swrite(me,"│        by Dave Haber         │ ──────────▄▄▄▄▄▄▄────");
  1044.         win_cursor(me,7,12); win_swrite(me,"└──────────────────────────────┘ ───────▄▄▄▄▄▄▄▄▄─────");
  1045.         win_cursor(me,8,12); win_swrite(me,"       Copyright (C) 1992        ────▄▄▄▄▄▄▄▄▄▄▄──────");
  1046.         win_cursor(me,9,12); win_swrite(me,"   Quarterdeck Office Systems    ─▄▄▄▄▄▄▄▄▄▄▄▄▄───────");
  1047.         win_cursor(me,5,30); win_swrite(me,PGMVER);
  1048.         }
  1049.     else
  1050.         {
  1051.         win_cursor(me,3,5); win_swrite(me,"┌──────────────────────────────┐");
  1052.         win_cursor(me,4,5); win_swrite(me,"│ DESQview File Search Utility │");
  1053.         win_cursor(me,5,5); win_swrite(me,"│         Version              │");
  1054.         win_cursor(me,6,5); win_swrite(me,"│        by Dave Haber         │");
  1055.         win_cursor(me,7,5); win_swrite(me,"└──────────────────────────────┘");
  1056.         win_cursor(me,8,5); win_swrite(me,"       Copyright (C) 1992       ");
  1057.         win_cursor(me,9,5); win_swrite(me,"   Quarterdeck Office Systems   ");
  1058.         win_cursor(me,5,23); win_swrite(me,PGMVER);
  1059.         }
  1060.     if(immediate)
  1061.         clear=1;
  1062. }
  1063.  
  1064.  
  1065. void getsmall(void)
  1066. {
  1067. if(!small)
  1068.     {
  1069.     win_allow(me,ALW_HSIZE);
  1070.     win_allow(me,ALW_VSIZE);
  1071.     win_resize(me,14,42);
  1072.     win_disallow(me,ALW_HSIZE);
  1073.     win_disallow(me,ALW_VSIZE);
  1074.     win_redraw(me);
  1075.     }
  1076.  
  1077. if(small)
  1078.     {
  1079.     win_allow(me,ALW_HSIZE);
  1080.     win_allow(me,ALW_VSIZE);
  1081.     win_resize(me,14,78);
  1082.     win_disallow(me,ALW_HSIZE);
  1083.     win_disallow(me,ALW_VSIZE);
  1084.     win_redraw(me);
  1085.     }
  1086.  
  1087. if(!small)
  1088.     small=1;
  1089. else
  1090.     small=0;
  1091.  
  1092. }
  1093.  
  1094.  
  1095. void fin(void)
  1096. {
  1097.  
  1098.     win_allow(me,ALW_HSIZE);
  1099.     win_allow(me,ALW_VSIZE);
  1100.     win_allow(me,ALW_HSCROLL);
  1101.     win_allow(me,ALW_VSCROLL);
  1102.     
  1103.     win_attr(me,winattr);
  1104.     win_frattr(me,255,frameattr);
  1105.  
  1106.     win_resize(me,sizerow,sizecol);
  1107.     win_move(me,posrow,poscol);
  1108.     
  1109.     win_cursor(me,0,0);
  1110.     win_redraw(me);
  1111.     
  1112.     cls();
  1113.     
  1114.     api_exit();
  1115.     exit(0);
  1116.  
  1117. }
  1118.